package com.boot.security.server.dao.mffl;

import java.util.List;
import java.util.Map;

import com.boot.security.server.model.mffl.MfflRefund;
import com.boot.security.server.model.mffl.Vo.MfflRefundVo;
import org.apache.ibatis.annotations.*;

import com.boot.security.server.model.mffl.MfflRefund;

@Mapper
public interface MfflRefundDao {

    @Select("select * from mffl_refund t where t.id = #{id}")
    MfflRefund getById(Long id);

    @Delete("delete from mffl_refund where id = #{id}")
    int delete(Long id);

    int update(MfflRefund mfflRefund);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into mffl_refund(userid, implementid, orderid, paynumber, paymerchantnumber, refundnumber, refundreason, refundstate, money, actualamount, refundtime, createTime, updateTime, confirmrefundtim, refundname) values(#{userid}, #{implementid}, #{orderid}, #{paynumber}, #{paymerchantnumber}, #{refundnumber}, #{refundreason}, #{refundstate}, #{money}, #{actualamount}, #{refundtime}, #{createTime}, #{updateTime}, #{confirmrefundtim}, #{refundname})")
    int save(MfflRefund mfflRefund);
    
    int count(@Param("params") Map<String, Object> params);

    List<MfflRefundVo> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);

    /**
     * 通过订单id查找退款表
     * @param orderid 订单id
     * @return
     */
    @Select("select * from mffl_refund t where t.orderid = #{orderid}")
    MfflRefund getByorderId(Long orderid);

    @Update("update mffl_refund set refundstate = #{refundstate},confirmrefundtim=now() where id = #{id} ")
    void updateState(@Param("id") Long id,@Param("refundstate") int refundstate);
}
